use strict;
use File::Find;
my $dir = shift || die "Please input a directory!!!";

open NAME_FILE ,"> ./cwkshell_files_resources.grd"  or die("can not open file");
open TEMP_TXT ,"> ./TEMP.txt"  or die("can not open file");
print NAME_FILE '<?xml version="1.0" encoding="UTF-8"?>';
print NAME_FILE '<grit latest_public_release="0" current_release="1">';
 print NAME_FILE '<outputs>';
 print NAME_FILE  ' <output filename="grit/cwkshell_files_resources.h" type="rc_header">';
 print NAME_FILE    '<emit emit_type="prepend"></emit>';
  print NAME_FILE  '</output>';
  print NAME_FILE  '<output filename="cwkshell_files_resources.pak" type="data_package" />';
  print NAME_FILE  '<output filename="cwkshell_files_resources.rc" type="rc_all" />';
 print NAME_FILE  '</outputs>';
  print NAME_FILE '<translations />';
  print NAME_FILE '<release seq="1">';
  print NAME_FILE ' <includes>';
   print NAME_FILE  ' <include name="IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE" file="files/shell_devtools_discovery_page.html" type="BINDATA" />';
   print NAME_FILE  ' <include name="IDR_CONTENT_SHELL_LAYOUT_TEST_CONTROLLER_JS" file="files/layout_test_controller.js" type="BINDATA" />';
find (\&handle,$dir);
sub handle{
        my $file_name = $File::Find::name;
    	next unless $file_name =~ /\..+$/;
      
         print NAME_FILE '<include name="IDR_';
       my $file_name_tmp = $file_name;
     $ file_name_tmp =~ s/\//_/g;
       $ file_name_tmp =~ s/\./_/g;
       $ file_name_tmp =~ s/-/_/g;
         print NAME_FILE uc($file_name_tmp);
         print NAME_FILE '" file="';
      print NAME_FILE $file_name.'" type="BINDATA" />'."\n";


      print TEMP_TXT "shell_webui_data_source->add_resource_path(\"".$_."\",IDR_".uc($file_name_tmp)."); \n";
    
}
print NAME_FILE ' </includes> </release></grit>';